package com.hpeu_01.day0126.homework;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * 第四题：自定义一个Student类，有私有属性（age、name、sex），
 * 有一个show方法，通过反射获取一个类的属性、方法、构造器的名称。
 */
public class Test02 {
    public static void main(String[] args) {
        Class<Students> clazz = Students.class;
        System.out.println("Students类中的属性名称：");
        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
            System.out.println(field.getName());
        }
        System.out.println("Students类中的方法名称：");
        Method[] methods = clazz.getDeclaredMethods();
        for (Method method : methods) {
            System.out.println(method.getName());
        }
        System.out.println("Students类中的构造器名称：");
        Constructor<?>[] constructors = clazz.getDeclaredConstructors();
        for (Constructor<?> constructor : constructors) {
            System.out.println(clazz.getSimpleName());
        }
    }
}
class Students{
    private Integer age;
    private String name;
    private String sex;

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Students(Integer age, String name, String sex) {
        this.age = age;
        this.name = name;
        this.sex = sex;
    }

    public Students() {
    }

    public void show(){

    }
}